/* sharedmemory.h
int getshm(int identif);
int creashm(int identif);
int elishm(int shmid);
*/

/*
 *  Hago el attach a la SHM
 *      ShmPTR = (struct Memory *) shmat(ShmID, NULL, 0);
 *           if ((int) ShmPTR == -1) {
 *               printf("*** shmat error (server) ***\n");
 *               exit(1);
 *           }
 *
 *  Hago el dettach
 *  shmdt((void *) ShmPTR);
 *
 */

int creashm(int identif)					/* Para crear una shared memory */
{
	key_t clave;
	clave = ftok(DIRECTORIO, identif);
	return ( shmget(clave, sizeof(int), IPC_CREAT|0666) );
}

int getshm(int identif)						/* Para conectarse a una shared memory */
{
	key_t clave;
	clave = ftok(DIRECTORIO, identif);
	return ( shmget(clave, sizeof(int), 0666) );
}

int elishm(int shmid)
{
	struct shmid_ds *buf;					/* The buf argument is a pointer to a shmid_ds structure, defined in <sys/shm.h> */
	return( shmctl(shmid, IPC_RMID, buf) );
}
